package com.fxl.majiang.config;

import com.fxl.majiang.user.User;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fengxinglei
 * @date 2022/8/1 22:57
 * @description 用户列表
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "register")
public class UserConfig {
    private List<User> users;

    public User getByUserId(String userId) {
        for (User user: users) {
            if (user.getId().equals(userId)) {
                return user;
            }
        }
        return null;
    }

    public List<User> getByIds(List<String> userIds) {
        List<User> userList = new ArrayList<>();
        for (User user: users) {
            if (userIds.contains(user.getId())) {
                userList.add(user);
            }
        }
        return userList;
    }
}
